package com.ruoyi.web.controller.pcommerce;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pcommerce.domain.PositionCommerce;
import com.ruoyi.pcommerce.service.IPositionCommerceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 帮养之家位置信息Controller
 *
 * @author zhezhi
 * @date 2022-10-02
 */
@RestController
@RequestMapping("/position/pcommerce")
public class PositionCommerceController extends BaseController
{
    @Autowired
    private IPositionCommerceService positionCommerceService;

    /**
     * 查询帮养之家位置信息列表
     */
    @PreAuthorize("@ss.hasPermi('position:pcommerce:list')")
    @GetMapping("/list")
    @ApiOperation("查询帮养之家位置信息列表")
    public TableDataInfo list(PositionCommerce positionCommerce)
    {
        startPage();
        List<PositionCommerce> list = positionCommerceService.selectPositionCommerceList(positionCommerce);
        return getDataTable(list);
    }

    /**
     * 导出帮养之家位置信息列表
     */
    @PreAuthorize("@ss.hasPermi('position:pcommerce:export')")
    @Log(title = "帮养之家位置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation("导出帮养之家位置信息列表")
    public void export(HttpServletResponse response, PositionCommerce positionCommerce)
    {
        List<PositionCommerce> list = positionCommerceService.selectPositionCommerceList(positionCommerce);
        ExcelUtil<PositionCommerce> util = new ExcelUtil<PositionCommerce>(PositionCommerce.class);
        util.exportExcel(response, list, "帮养之家位置信息数据");
    }

    /**
     * 获取帮养之家位置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('position:pcommerce:query')")
    @GetMapping(value = "/{commerceId}")
    @ApiOperation("获取帮养之家位置信息详细信息")
    public AjaxResult getInfo(@PathVariable("commerceId") Long commerceId)
    {
        return AjaxResult.success(positionCommerceService.selectPositionCommerceByCommerceId(commerceId));
    }

    /**
     * 新增帮养之家位置信息
     */
    @PreAuthorize("@ss.hasPermi('position:pcommerce:add')")
    @Log(title = "帮养之家位置信息", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增帮养之家位置信息")
    public AjaxResult add(@RequestBody PositionCommerce positionCommerce)
    {
        return toAjax(positionCommerceService.insertPositionCommerce(positionCommerce));
    }

    /**
     * 修改帮养之家位置信息
     */
    @PreAuthorize("@ss.hasPermi('position:pcommerce:edit')")
    @Log(title = "帮养之家位置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改帮养之家位置信息")
    public AjaxResult edit(@RequestBody PositionCommerce positionCommerce)
    {
        return toAjax(positionCommerceService.updatePositionCommerce(positionCommerce));
    }

    /**
     * 删除帮养之家位置信息
     */
    @PreAuthorize("@ss.hasPermi('position:pcommerce:remove')")
    @Log(title = "帮养之家位置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commerceIds}")
    @ApiOperation("删除帮养之家位置信息")
    public AjaxResult remove(@PathVariable Long[] commerceIds)
    {
        return toAjax(positionCommerceService.deletePositionCommerceByCommerceIds(commerceIds));
    }
}
